<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="js/jquery-1.11.0.min.js"></script>
    <script src="js/getParameter.js"></script>
</head>
<script>
    var bbb;
    $(function () {
        $.ajax({
            url:"/student/gettypes",
            type:"post",
            datatype:"json",
            success:function (data) {
                $.each(data,function (index,obj) {

                    if(obj.cid==bbb){
                        var html = $("<option selected></option>").val(obj.cid).html(obj.cname);
                    }
                    var html = $("<option></option>").val(obj.cid).html(obj.cname);
                    $("#a").append(html)
                })
            }
        })

        var id = getParameter("id");
        $("#ccc").val(id);
        $.get("/student/findOne",{id:id},function(data) {
            $("#name").val(data.name);
            $("#age").val(data.age);
            $("#gender").val(data.gender);
            $("#telephone").val(data.telephone);
            $("#email").val(data.email);
            $("#a").val(data.cid);
            bbb=data.cid;
        })
    })

    function tj(){
        var data1 = $("#addForm").serialize();
        $.ajax({
            url:"/student/updatestu",
            type:"post",
            datatype:"json",
            data:data1,
            success:function(data){
                if(data.flag){
                    location.href="index.html";
                }
            }
        })

    }
</script>
<body>
<h1 align="center">修改信息</h1>
<form id="addForm" method="post">
    <input type="hidden" id="ccc"name="id" >
    <table id="abc" align="center">
        <tr>
            <td>姓名</td>
            <td><input id="name" name="name"></td>
        </tr>
        <tr>
            <td>性别</td>
            <td><input id="gender" name="gender"></td>
        </tr>
        <tr>
            <td>年龄</td>
            <td><input id="age" name="age"></td>
        </tr>
        <tr>
            <td>电话</td>
            <td><input id="telephone" name="telephone"></td>
        </tr>
        <tr>
            <td>邮箱</td>
            <td><input id="email" name="email"></td>
        </tr>
        <tr>
            <td>班级</td>
            <td>
                <select  id="a" name="cid">
                    <option>请选择</option>
                </select>
            </td>
        </tr>
    </table>
    <center>
        <button type="reset">重置</button>
        <input  type="button" value="提交" onclick="tj()">
        <button>返回</button>
    </center>

</form>
</body>
</html>